package com.ruoyi.web.controller.vis;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.drug.domain.DrugPhysic;
import com.ruoyi.system.domain.SysCheck;
import com.ruoyi.system.vis.service.VisPreDrugService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/vis/predrug")
public class VisPreDrugController extends BaseController {
    @Autowired
    private VisPreDrugService visPreDrugService;

    //添加药品处方
    @PutMapping("/{drugIds}")
    public AjaxResult add(@PathVariable Long[] drugIds, @Validated @RequestBody Long patientId)
    {
        System.out.println("-=================================================");
        System.out.println(patientId);
        for (Long drugId : drugIds) {
            System.out.println(drugIds);
        }
        return toAjax(visPreDrugService.add(patientId,drugIds));
    }
    //批量查询
    @PostMapping("/temDrugList")
    public TableDataInfo list(@RequestBody long patientId){
        startPage();
        List<DrugPhysic> list = visPreDrugService.selectCheckByPatientId(patientId);
        return getDataTable(list);
    }
}
